package com.lyfei.yd.domain.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.lyfei.yd.domain.BaseEntity;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;

@Getter
@Setter
@TableName("t_address")
public class Address extends BaseEntity<Address> {
    private String name;

    private Long userId;

    private Integer provinceId;

    private Integer cityId;

    private Integer areaId;

    @TableField(exist = false)
    private String provinceName;

    @TableField(exist = false)
    private String cityName;

    @TableField(exist = false)
    private String areaName;

    private String address;

    private String mobile;

    private Boolean isDefault;

    private Date createTime;

    private Date updateTime;

    @TableLogic
    private Boolean deleted;

    @TableField(exist = false)
    private String detailedAddress;

    public String getDetailedAddress() {
        if (this.provinceName == null || this.cityName == null || this.areaName == null) {
            return this.address;
        }
        return this.provinceName + this.cityName + this.areaName + this.address;
    }
}
